import { stringifyQuery } from "vue-router";
import { createStore } from "vuex";

export default createStore({
  state: {
    list: JSON.parse(localStorage.getItem("list") as string) || [
      { title: "chifan", check: false },
    ],
  },
  mutations: {
    add(state, payload) {
      state.list.push({
        title: payload,
        check: false,
      });
      localStorage.setItem("list", JSON.stringify(state.list));
    },
    del(state, payload) {
      state.list.splice(payload, 1);
      localStorage.setItem("list", JSON.stringify(state.list));
    },
    clear(state, payload) {
      state.list = payload;
      localStorage.setItem("list", JSON.stringify(state.list));
    },
  },
  actions: {},
  modules: {},
});
